package com.tengju.data.domain.model.user;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum DominationMemberSortType {

    MARKET_INDEX_ASC(1,"市场指数升序","current_month_achievement asc,id_code asc"),
    MARKET_INDEX_DESC(2,"市场指数降序","current_month_achievement desc,id_code desc"),
    SERVICE_PROVIDER_ASC(3,"服务商数升序","serviceProviderTotal asc,id_code asc"),
    SERVICE_PROVIDER_DESC(4,"服务商数降序","serviceProviderTotal desc,id_code desc"),
    DEALER_ASC(5,"经销商数升序","domination_dealer_num asc,id_code asc"),
    DEALER_DESC(6,"经销商数降序","domination_dealer_num desc,id_code desc"),
    REGISTER_TIME_ASC(7,"注册时间升序","register_time asc,id_code asc"),
    REGISTER_TIME_DESC(8,"注册时间降序","register_time desc,id_code desc"),
    USER_LEVEL_FOUR_ASC(9,"黑钻数升序","user_level_four_cnt asc,id_code asc"),
    USER_LEVEL_FOUR_DESC(10,"黑钻数降序","user_level_four_cnt desc,id_code desc"),
    USER_LEVEL_THREE_ASC(11,"白金数升序","user_level_three_cnt asc,id_code asc"),
    USER_LEVEL_THREE_DESC(12,"白金数降序","user_level_three_cnt desc,id_code desc"),
    USER_LEVEL_TWO_ASC(13,"粉卡数升序","user_level_two_cnt asc,id_code asc"),
    USER_LEVEL_TWO_DESC(14,"粉卡数降序","user_level_two_cnt desc,id_code desc"),
    ;

    Integer val;
    String desc;
    String sql;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public String getSql() {
        return sql;
    }

    public static DominationMemberSortType fromVal(Integer val) {

        if (val == null) {
            return DominationMemberSortType.REGISTER_TIME_DESC;
        }

        for (DominationMemberSortType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return DominationMemberSortType.REGISTER_TIME_DESC;
    }
}
